/**
 * Copyright (C) 2017 - 2020 https://github.com/joewee
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bifrost.entity;

import javax.persistence.*;
import java.util.Date;

/**
 *
 *优惠券日志
 *@author joewee
 *@version 1.0.0
 *@date 2018/7/6 11:02
 */
@Entity
@Table(name = "COUPON_HISTROY")
@NamedQuery(name = "CouponHistroy.findAll", query = "SELECT c FROM CouponHistroy c")
public class CouponHistroy {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    @Column(name = "TRANSACTION_ID", unique = true, nullable = false)
    private Long transactionId;

    @Column(name = "COUPON_DETAIL_ID",nullable = false)
    private Long couponDetailId;

    @Column(name = "CUSTOMER_ID")
    private Long customerId;

    @Column(name = "ORDER_NUMBER")
    private String orderNumber;

    @Column(name = "REMARK")
    private String remark;

    @Column(name = "OPERATION",nullable = false)
    @Enumerated(value = EnumType.STRING)
    private Operation operation;

    @Column(name = "MODIFY_DATE",nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date modifyDate = new Date();

    public CouponHistroy() {
    }

    public CouponHistroy(Long transactionId, Long couponDetailId,Long customerId, String orderNumber,   Operation operation,String remark) {
        this.transactionId = transactionId;
        this.couponDetailId = couponDetailId;
        this.customerId = customerId;
        this.orderNumber = orderNumber;
        this.remark = remark;
        this.operation = operation;
    }

    /**
     * NEW:新建
     * REFUND：优惠券使用过后退还为未使用状态
     * RETURN：优惠券未使用退还为未领取状态
     */
    public enum Operation{
        NEW,GENERATE,QUERY,CONSUME,CANCEL,REFUND,RETURN;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getTransactionId() {
        return transactionId;
    }

    public void setTransactionId(Long transactionId) {
        this.transactionId = transactionId;
    }

    public Long getCouponDetailId() {
        return couponDetailId;
    }

    public void setCouponDetailId(Long couponDetailId) {
        this.couponDetailId = couponDetailId;
    }

    public String getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(String orderNumber) {
        this.orderNumber = orderNumber;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Operation getOperation() {
        return operation;
    }

    public void setOperation(Operation operation) {
        this.operation = operation;
    }

    public Date getModifyDate() {
        return modifyDate;
    }

    public void setModifyDate(Date modifyDate) {
        this.modifyDate = modifyDate;
    }

    public Long getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }
}
